As the topic describes I need to convert unicode char array to array<unsigned char,1>^
Code:
if ( saveFileDialog1->ShowDialog() == ::DialogResult::OK )
{
if ( (myStream = saveFileDialog1->OpenFile()) != nullptr )
{
array<String^>^ stringArray;
array<unsigned char,1>^ charArray;
stringArray=this->input->Split('\n');
for (int index=0;index<=stringArray->Length;index++){
charArray=(array<unsigned char, 1>^)stringArray[index]->ToCharArray();//I get a cast exception here.
myStream->Write(charArray,0,charArray->Length);
}
filename = saveFileDialog1->FileName;
myStream->Close();
}
}
I also tried marshalling the stringArray[index] to a std::string and using c_str() but that didn't work either.